Skip to content

Implement Invalidate search type for Potential Match rules (CO-2690) #70

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

stein
Copy link

@stein stein commented Nov 5, 2025

Extend support for the Invalidate search type to Potential Match rules. Drop a Potential Match to No Match when the Invalidate attribute does not match.

Copy link
Contributor

@benno benno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this overall capability be configurable? Partially for backwards compatibility, but also because not every deployment might want potential matches to drop to no matches.

This could perhaps most easily be done by splitting the "Invalidate" search type into (eg) "Invalidate Canonical" and "Invalidate All". "Invalidate Canonical" would basically be the current search type relabeled, and would effectively be a no-op if set on a Potential Rule (probably the UI shouldn't permit that, see also CO-2181). "Invalidate All" might not be the best label.

$results = $potentialMatches->getRawResults();

// Check if any Attribute Rules in "Invalidate" mode will demote this result.
foreach($results as $rowId => $attrs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop is fairly duplicative of the canonical check, and perhaps should be refactored into a separate call.

}

// No need to continue with any loop
break 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 2 correct here? (It's 3 in the canonical loop.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be "break 2", not "break 3" because we need to continue processing any other potential matches to determine if they also should be invalidated.

Once we have successfully dropped a potential match to no match, there's no need to continue with the loop for rule attributes or for rules. But we need to continue with the loop that iterates through all of the $results.

Comment on lines +1010 to +1013
$found = $potentialMatches->remove($rowId);
if (!$found) {
Log::write('warning', $sor . "/" . $sorid . " Invalidate mode - error occurred removing result from potential match result set ". $rowId . "\t" . $results[$rowId]['sorid']);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under what circumstances is this error likely to happen and be actionable by an administrator?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like one of those "this line should never be printed" messages. This would only occur if we tried to remove() a potential match from the result set because it passes the invalidate test, but remove() can't find the rowId in the result set. It seems unlikely to occur.

I could make this scenario fatal and throw a RuntimeException in case it does happen.

@stein
Copy link
Author

stein commented Nov 24, 2025

Should this overall capability be configurable? Partially for backwards compatibility, but also because not every deployment might want potential matches to drop to no matches.

This could perhaps most easily be done by splitting the "Invalidate" search type into (eg) "Invalidate Canonical" and "Invalidate All". "Invalidate Canonical" would basically be the current search type relabeled, and would effectively be a no-op if set on a Potential Rule (probably the UI shouldn't permit that, see also CO-2181). "Invalidate All" might not be the best label.

Currently, the "Invalidate" search type has no effect when applied to a Potential match rule. So, I wasn't particularly concerned about breaking compatibility, as no existing Potential match rules should (intentionally) be configured with "Invalidate" that would be affected by this change.

Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants